<template>
  <el-form :model="form" label-width="120px">
    <el-form-item label="推荐名称">
      <el-input v-model="recommend.name" />
    </el-form-item>
    <el-form-item label="超链接">
      <el-input v-model="recommend.url" />
    </el-form-item>
    <el-form-item label="推荐图">
      <ImgUpload :imgurl="recommend.img" @seturl="handleImg" />
    </el-form-item>

    <el-form-item label="广告描述">
      <el-input v-model="recommend.desc" type="textarea" />
    </el-form-item>

    <el-form-item label="是否上架">
      <el-switch v-model="recommend.isshow" />
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="handleSubmit">修改</el-button>
      <el-button>重置</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import request from "../../server/request";
import { recommendUpdate } from "../../api/product";
import ImgUpload from "../../components/ImgUpload.vue";
export default {
  components: {
    ImgUpload,
  },
  data() {
    return {
      recommend: null,
    };
  },
  created() {
    this.recommend = this.$route.query;
  },
  methods: {
    handleSubmit() {
      console.log(this.recommend);
      recommendUpdate(this.recommend).then((res) => {
        console.log(res);
        this.$router.back();
      });
    },
    handleImg(url) {
      console.log(url);
      this.recommend.img = url;
    },
  },
};
</script>

<style lang="scss" scoped></style>
